package com.huike.web.controller.report;


import com.huike.report.domain.vo.IndexTodayInfoVO;
import com.huike.report.domain.vo.IndexVo;
import com.huike.report.domain.vo.WinnerList;
import org.apache.poi.ss.formula.functions.Now;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.huike.common.core.domain.AjaxResult;
import com.huike.report.service.IReportService;
import sun.java2d.pipe.SpanShapeRenderer;

import javax.xml.crypto.Data;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.concurrent.ExecutionException;

@RestController
@RequestMapping("/index")
public class IndexController {

    @Autowired
    private IReportService reportService;


    /**
     * 首页--基础数据统计
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/getBaseInfo")
    public AjaxResult getBaseInfo(@RequestParam("beginCreateTime") String beginCreateTime,
                                  @RequestParam("endCreateTime") String endCreateTime){
        return AjaxResult.success(reportService.getBaseInfo(beginCreateTime,endCreateTime));
    }
    @GetMapping("/getTodayInfo")
    public AjaxResult getTodayInfo() throws ExecutionException, InterruptedException {
//        IndexTodayInfoVO indexTodayInfoVO = new IndexTodayInfoVO();
//        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
//        String now = simpleDateFormat.format(new Date());
//        Integer todayBusinessNum=reportService.getTodayBusinessNum("lisi",now);
//        Integer setTodayCluesNum=reportService.getTodayBusinessNum("zhangsan",now);
//        indexTodayInfoVO.setTodayBusinessNum(todayBusinessNum);
//        indexTodayInfoVO.setTodayCluesNum(setTodayCluesNum);
//        indexTodayInfoVO.setTodayContractNum(3);
//        indexTodayInfoVO.setTodaySalesAmount(4.0);
        IndexTodayInfoVO indexTodayInfoVO = reportService.getTodayInfo();
    return AjaxResult.success(indexTodayInfoVO);
    }
    @GetMapping("/getTodoInfo")
    public AjaxResult getTodoInfo(String beginCreateTime,String endCreateTime){
//        IndexTodayInfoVO indexTodayInfoVO = new IndexTodayInfoVO();
//        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
//        String now = simpleDateFormat.format(new Date());
//        Integer todayBusinessNum=reportService.getTodayBusinessNum("lisi",now);
//        Integer setTodayCluesNum=reportService.getTodayBusinessNum("zhangsan",now);
//        indexTodayInfoVO.setTodayBusinessNum(todayBusinessNum);
//        indexTodayInfoVO.setTodayCluesNum(setTodayCluesNum);
//        indexTodayInfoVO.setTodayContractNum(3);
//        indexTodayInfoVO.setTodaySalesAmount(4.0);
        IndexVo todoInfo = reportService.getTodoInfo(beginCreateTime, endCreateTime);
        return AjaxResult.success(todoInfo);
    }

    @GetMapping("/businessChangeStatistics")
    public AjaxResult businessChangeStatistics(String beginCreateTime,String endCreateTime){
        List<WinnerList> list = reportService.businessChangeStatistics(beginCreateTime, endCreateTime);
        return AjaxResult.success(list);
    }
    @GetMapping("/salesStatistic")
    public AjaxResult salesStatistic(String beginCreateTime,String endCreateTime){
        IndexVo todoInfo = reportService.getTodoInfo(beginCreateTime, endCreateTime);
        return AjaxResult.success();
    }

}